package cs.helsinki.fi.rio.matrixmult;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/* Accepts files. Returns matrixes.
 * @author Ixtor
 */
public class MatrixBuilder {
    

    public static double[][] BuildMatrix (File file){
        
        Scanner scanner = makeScanner(file);
        int matrixSize = scanner.nextInt();
        double [][] matrix = new double [matrixSize][matrixSize];
            for(int row = 0; row < matrixSize; row++){
                for (int col = 0; col < matrixSize; col++){
                    matrix[row][col] = Double.parseDouble(scanner.next());
                }
            }
            
        return matrix;
    }

    private static Scanner makeScanner(File file){
        Scanner scanner = null;
        try {
            scanner = new Scanner(file);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(MatrixBuilder.class.getName()).log(Level.SEVERE, null, ex);
        }
        return scanner;
    }

    
}
